import { Button, Form, Input } from "antd";
import style from "./index.module.less";
import api from "../../api";
import { ILoginParams } from "../../types/api";
import storage from "../../utils/storage";
const onFinish = async (params: ILoginParams) => {
  const data = await api.login(params);
  console.log("data:", data);
  storage.set("token", data.data);
};
const onFinishFailed = () => {
  console.log("Failed:");
};
const Login = () => {
  return (
    <div className={style.login}>
      <div className={style.loginWrapper}>
        <h1 className={style.title}>系统登陆</h1>
        <Form
          name="basic"
          initialValues={{ remember: true }}
          onFinish={onFinish}
          onFinishFailed={onFinishFailed}
          autoComplete="off"
        >
          <Form.Item
            label="Username"
            name="userName"
            rules={[{ required: true, message: "Please input your username!" }]}
          >
            <Input />
          </Form.Item>

          <Form.Item
            label="Password"
            name="userPwd"
            rules={[{ required: true, message: "Please input your password!" }]}
          >
            <Input.Password />
          </Form.Item>
          <Form.Item>
            <Button type="primary" htmlType="submit" block>
              Submit
            </Button>
          </Form.Item>
        </Form>
      </div>
    </div>
  );
};
export default Login;
